<?php date_default_timezone_set('Australia/Brisbane'); ?>
<div id="assessment_viewer_sub">
    <p>
    <a id="bkbut" href="<?php echo site_url("/assessment"); ?>">&#60; Back to all assessments</a>
    
    <?php
	$nowU = date('U');
	$nowU = $nowU + 604800;
	$nowUa = date('U');
	$format = 'Y-m-d H:i:s';
	$date = DateTime::createFromFormat($format, $item_details['due_date']);
	$dateU = $date->format('U');
	$time = $date->format('G:i');
	$date = $date->format('d/m/Y');
	?>
    
    <?php
    
   	if($submitted){
			$dateS = DateTime::createFromFormat($format, $submitted[0]['timestamp']);
			$dateSU = $dateS->format('U');
			$timeS = $dateS->format('G:i');
			$dateS = $dateS->format('d/m/Y');
			if($submitted[0]['marked']!=0){
				$pres = $submitted[0]['result'];
					if($pres>=85){$gres=7;$tres='High Distinction';}
					else if($pres>=75){$gres=6;$tres='Distinction';}
					else if($pres>=65){$gres=5;$tres='Credit';}
					else if($pres>=50){$gres=4;$tres='Pass';}
					else if($pres>=40){$gres=3;$tres='Marginal Fail';}
					else if($pres>=25){$gres=2;$tres='Fail';}
					else {$gres=1;$tres='Low Fail';}
				$marktxt = 'marked with a grade of: <em>'.$tres.'</em> ('.$gres.' / '.$pres.'%)';
			}else{
				$marktxt = 'has not yet been marked';
			}
   		echo '<b class="enc"><i> Submitted on: '.$dateS.' at '.$timeS.'</i>- '.$marktxt.'</b>';
   	}else{
   		echo '	<form action="'.site_url("/assessment/submit").'" method="post">'."\n";
   		echo '  <input type="hidden" name="itemid" value="'.$item_details['assessment_id'].'" />'."\n";
   		echo '	<input type="file" name="submission" size="40" /><br />'."\n";
   		echo '  <input type="submit" value="Submit Assessment" />'."\n";
   		echo '  </form>';
   		
   	}
   	
   	?></p>
</div>
